package com.guoxin.chapter3.waitnotify.producerconsumer;

/**
 * @author guoxin
 * @date 2019年8月22日
 */
public class Producer {
	private Object lock;

	public Producer(Object lock) {
		super();
		this.lock = lock;
	}
	
	public void setValue(){
		try {
			synchronized (lock) {
				if(!ValueObject.value.equals("")){
					lock.wait();
				}
				String value = System.currentTimeMillis()+"_"+System.nanoTime();
				System.out.println("set 的值是："+value);
				ValueObject.value = value;
				lock.notify();
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	
}
